<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title>九铭资产管理-九铭注册</title>
		<link rel="stylesheet" href="/Public/Home/css/jiuming.css" />
		<link rel="shortcut icon" href="http://jlzpublicbucket.oss-cn-hangzhou.aliyuncs.com/assets/jiujming.ico" type="image/x-icon">
	</head>
	<body>
		
		<div class="register-top">
			<div class="register-top-content">
				 <div class="register-top-logo"></div>
				 <div class="register-top-text">注册</div>
			</div>
		</div>
		
		<div class="register-content">
			<div class="register-content-left">
				<div class="input-box">
					<div class="item">用户注册类型：</div>
					<div class="inpput-text radio" id="type">
						<label>
							<input type="radio" name="type" value="1" checked />个人
						</label>
						<label>
							<input type="radio" name="type" value="2" />机构
						</label>
					</div>
				</div>
				
				<!--个人-->
				<div class="personal">
					<div class="input-box">
						<div class="item">姓名：</div>
						<div class="inpput-text">
							<input type="text" name="name" value="" id="name"/>
						</div>
					</div>
					<div class="input-box">
						<div class="item">证件类型：</div>
						<div class="inpput-text">
							<select name="paper-type" class="select" id="paper-type">
		    				<option value="" selected disabled>选择证件类型</option>
	    					<option value="1">身份证</option>
		    				<option value="2">护照</option>
		    			</select>
	    			</div>
					</div>
					<div class="input-box">
						<div class="item">证件号码：</div>
						<div class="inpput-text">
							<input type="text" name="paper-no" value="" id="paper-no"/>
						</div>
					</div>
					<div class="input-box">
						<div class="item">手机号码：</div>
						<div class="inpput-text">
							<input type="text" name="tel1" value="" id="tel1"/>
						</div>
					</div>
					<div class="input-box">
						<div class="item">密码设置：</div>
						<div class="inpput-text">
							<input type="password" name="pwd11" value="" id="pwd11" placeholder="字母开头，6-18位，只含字符、数字和下划线"/>
						</div>
					</div>
					<div class="input-box">
						<div class="item">确认密码：</div>
						<div class="inpput-text">
							<input type="password" name="pwd12" value="" id="pwd12"/>
						</div>
					</div>
					<div class="input-box">
						<div class="item">验证码：</div>
						<div class="inpput-text">
							<input type="text" name="code1" value="" id="code1"/>
							<button class="btn" id="getCode1">验证码</button>
						</div>
					</div>
					<div class="input-box">
						<div class="item"></div>
						<div class="inpput-text">
							<button class="btn" id="sub1">注 &nbsp;&nbsp;册</button>
						</div>
					</div>
					<div class="input-box">
							<p>已有账号？<a class="login" href="{:U('Index/login',array('token' => 'dvaglg1469847559'))}">登录</a></p>
					</div>
				</div>
				
				<!--机构-->
				<div class="mechanism hidden">
					<div class="input-box">
						<div class="item">机构投资者名称：</div>
						<div class="inpput-text">
							<input type="text" name="me-name" value="" id="me-name"/>
						</div>
					</div>
					<div class="input-box">
						<div class="item">营业执照号码：</div>
						<div class="inpput-text">
							<input type="text" name="business-no" value="" id="business-no"/>
						</div>
					</div>
					<div class="input-box">
						<div class="item">法定代表人：</div>
						<div class="inpput-text">
							<input type="text" name="legal-person" value="" id="legal-person"/>
						</div>
					</div>
					<div class="input-box">
						<div class="item">联系人：</div>
						<div class="inpput-text">
							<input type="text" name="contacts" value="" id="contacts"/>
						</div>
					</div>
					<div class="input-box">
						<div class="item">注册资本：</div>
						<div class="inpput-text">
							<input type="text" name="capital" value="" id="capital"/>
						</div>
					</div>
					<div class="input-box">
						<div class="item">公司性质：</div>
						<div class="inpput-text">
							<input type="text" name="nature" value="" id="nature"/>
						</div>
					</div>
					<div class="input-box">
						<div class="item">住所：</div>
						<div class="inpput-text">
							<input type="text" name="address" value="" id="address"/>
						</div>
					</div>
					<div class="input-box">
						<div class="item">手机号码：</div>
						<div class="inpput-text">
							<input type="text" name="tel2" value="" id="tel2"/>
						</div>
					</div>
					<div class="input-box">
						<div class="item">密码设置：</div>
						<div class="inpput-text">
							<input type="password" name="pwd21" value="" id="pwd21" placeholder="字母开头，6-18位，只含字符、数字和下划线"/>
						</div>
					</div>
					<div class="input-box">
						<div class="item">确认密码：</div>
						<div class="inpput-text">
							<input type="password" name="pwd22" value="" id="pwd22"/>
						</div>
					</div>
					<div class="input-box">
						<div class="item">验证码：</div>
						<div class="inpput-text">
							<input type="text" name="code2" value="" id="code2"/>
							<button class="btn" id="getCode2">验证码</button>
						</div>
					</div>
					<div class="input-box">
						<div class="item"></div>
						<div class="inpput-text">
							<button class="btn" id="sub2">注 &nbsp;&nbsp;册</button>
						</div>
					</div>
					<div class="input-box">
						<!--<div class="item"></div>
						<div class="inpput-text">-->
							<p>已有账号？<a class="login" href="{:U('Index/login',array('token' => 'dvaglg1469847559'))}">登录</a></p>
						<!--</div>-->
					</div>
				</div>
			</div>
			<div class="register-content-right"></div>
			<div class="clear"></div>
		</div>
		
		<div class="register-footer">
			<p><a href="http://www.jiumingfund.com">http://www.jiumingfund.com</a></p>
		</div>
		
		
		<script type="text/javascript" src="/Public/Home/js/jquery.1.9.1.min.js"></script>
		<script>
			function getCode(obj,tel){
				$.ajax({
					url:"{:U('Index/getsms',array('token' => 'dvaglg1469847559'))}",
    				type:"POST",
    				dataType:"json",
    				data:{
    					tel:tel
    				},
    				success:function(data){
    					if(data.status ==1){
    						var i = 60;
    						obj.addClass("disabled");
    						var timer = setInterval(function(){
    							obj.text(i+"s后重试");
    							i--;
    							if(i == -1){
    								clearInterval(timer);
    								obj.removeClass("disabled");
    								obj.text("获取验证码");
    							}
    						},1000)
    					}else{
    						alert(data.msg);
    					}
    				}
    			})
				}
				
				$(function(){
					//切换注册类型
					$("#type label").bind('click',function(){
						var type = $(this).children('input:checked').val();
						if(type == 1){
							$(".personal").removeClass('hidden');
							$(".mechanism").addClass('hidden');
						}else if(type == 2){
							$(".personal").addClass('hidden');
							$(".mechanism").removeClass('hidden');
						}
					})
				
					//getCode绑定
					$("#getCode1").bind('click',function(){
						var father = $(this);
						var tel = $("#tel1").val();
						if(tel == ''){
							alert("请输入手机号码");
	    				$("#tel1").focus();
	    				return false;
						}
						if(father.hasClass('disabled')){
							return false;
						}else{
							getCode(father,tel);
						}
					})
					$("#getCode2").bind('click',function(){
						var father = $(this);
						var tel = $("#tel2").val();
						if(tel == ''){
							alert("请输入手机号码");
	    				$("#tel2").focus();
	    				return false;
						}
						if(father.hasClass('disabled')){
							return false;
						}else{
							getCode(father,tel);
						}
					})
				
					//个人注册
					$("#sub1").bind('click',function(){
						var type = 1;
						var name = $("#name").val();
	    			var paper_type = $("#paper-type option:checked").val();
	    			var paper_no = $("#paper-no").val();
	    			var tel = $("#tel1").val();
	    			var pwd1 = $("#pwd11").val();
	    			var pwd2 = $("#pwd12").val();
	    			var code = $("#code1").val();
	    			
	    			var reg_paper_type1 = /^(\d{15}$|^\d{18}$|^\d{17}(\d|X|x))$/;  //身份证
						var reg_paper_type2 = /^1[45][0-9]{7}|G[0-9]{8}|P[0-9]{7}|S[0-9]{7,8}|D[0-9]+$/;   //护照
						var reg_tel = /^1[3|4|5|7|8]\d{9}$/;     //手机
						var reg_pwd = /^[a-zA-Z]\w{5,17}$/;			//密码 ： 以字母开头，长度在6-18之间，只能包含字符、数字和下划线。
	    			
	    			if(name == ''){
	    				alert("请输入姓名");
	    				$("#name").focus();
	    				return false;
	    			}
	    			if(paper_type == ''){
	    				alert("请选择证件类型");
	    				$("#paper-type").focus();
	    				return false;
	    			}
	    			if(paper_no == ''){
	    				alert("请输入证件号码");
	    				$("#paper-no").focus();
	    				return false;
	    			}
	    			if(tel == ''){
	    				alert("请输入手机号码");
	    				$("#tel1").focus();
	    				return false;
	    			}
	    			if(pwd1 == ''){
	    				alert("请输入初始密码");
	    				$("#pwd11").focus();
	    				return false;
	    			}
	    			if(pwd2 == ''){
	    				alert("请确认初始密码");
	    				$("#pwd12").focus();
	    				return false;
	    			}
	    			if(code == ''){
	    				alert("请输入验证码");
	    				$("#code1").focus();
	    				return false;
	    			}
	    			
	    			if(paper_type == 1){
							if(!reg_paper_type1.test(paper_no)){
								alert("请输入正确的身份证号");
								$("#paper-no").focus();
								return false;
							}
						}else if(paper_type == 2){
							if(!reg_paper_type2.test(paper_no)){
								alert("请输入正确的护照");
								$("#paper-no").focus();
								return false;
							}
						}
						if(!reg_tel.test(tel)){
							alert("请输入正确的手机号码");
		    				$("#tel1").focus();
		    				return false;
						}
						if(!reg_pwd.test(pwd1)){
							alert("请输入 以字母开头，长度在6-18之间，只能包含字符、数字和下划线的密码。");
		    				$("#pwd1").focus();
		    				return false;
						}
						if(!reg_pwd.test(pwd2)){
							alert("请输入 以字母开头，长度在6-18之间，只能包含字符、数字和下划线的密码。");
		    				$("#pwd12").focus();
		    				return false;
						}
						if(pwd1 != pwd2){
							alert("两次输入的密码不一致，请修改");
		    				$("#pwd12").focus();
		    				return false;
						}
	    			
	    			$.ajax({
//	    				url:"http://v.wx91go.com/index.php?g=Wap&m=AssetsRegister&a=register&token=dvaglg1469847559&isWeb=1",
						url:"{:U('Index/register',array('token' => 'dvaglg1469847559'))}",
	    				type:"POST",
	    				dataType:"json",
	    				data:{
	    					type:type,
	    					name:name,
	    					paper_type:paper_type,
	    					paper_no:paper_no,
	    					tel:tel,
	    					password:pwd2,
	    					code:code
	    				},
	    				success:function(data){
	    					if(data.status == 1){
	    						window.location.href = "{:U('Assets/investigation_index',array('token' => 'dvaglg1469847559'))}";
	    					}else{
	    						alert(data.msg);
	    					}
	    				}
	    			})
					})
					
					//机构注册
					$('#sub2').bind('click',function(){
						var type = 2;
						var organization_name = $("#me-name").val();
	    			var licence_no = $("#business-no").val();
	    			var legal_person = $("#legal-person").val();
	    			var contacts_person = $("#contacts").val();
	    			var register_capital = $("#capital").val();
	    			var commpany_nature = $("#nature").val();
	    			var address = $("#address").val();
	    			var tel = $("#tel2").val();
	    			var pwd1 = $("#pwd21").val();
	    			var pwd2 = $("#pwd22").val();
	    			var code = $("#code2").val();
	    			
	    			var reg_pwd = /^[a-zA-Z]\w{5,17}$/;			//密码 ： 以字母开头，长度在6-18之间，只能包含字符、数字和下划线。
	    			var reg_tel = /^1[3|4|5|7|8]\d{9}$/;     //手机
	    			
	    			if(organization_name == ''){
	    				alert("请输入投资者名称");
	    				$("#me-name").focus();
	    				return false;
	    			}
	    			if(licence_no == ''){
	    				alert("请输入营业执照号码");
	    				$("#business-no").focus();
	    				return false;
	    			}
	    			if(legal_person == ''){
	    				alert("请输入法人代表");
	    				$("#legal-person").focus();
	    				return false;
	    			}
	    			if(contacts_person == ''){
	    				alert("请输入联系人");
	    				$("#contacts").focus();
	    				return false;
	    			}
	    			if(register_capital == ''){
	    				alert("请输入公司性质");
	    				$("#capital").focus();
	    				return false;
	    			}
	    			if(commpany_nature == ''){
	    				alert("请输入公司性质");
	    				$("#nature").focus();
	    				return false;
	    			}
	    			if(address == ''){
	    				alert("请输入地址");
	    				$("#address").focus();
	    				return false;
	    			}
	    			if(tel == ''){
	    				alert("请输入手机号码");
	    				$("#tel2").focus();
	    				return false;
	    			}
	    			if(pwd1 == ''){
	    				alert("请输入初始密码");
	    				$("#pwd21").focus();
	    				return false;
	    			}
	    			if(pwd2 == ''){
	    				alert("请确认初始密码");
	    				$("#pwd22").focus();
	    				return false;
	    			}
	    			if(code == ''){
	    				alert("请输入验证码");
	    				$("#code2").focus();
	    				return false;
	    			}
	    			if(!reg_tel.test(tel)){
							alert("请输入正确的手机号码");
	    				$("#tel2").focus();
	    				return false;
						}
	    			if(!reg_pwd.test(pwd1)){
							alert("请输入 以字母开头，长度在6-18之间，只能包含字符、数字和下划线的密码。");
	    				$("#pwd21").focus();
	    				return false;
						}
	    			if(!reg_pwd.test(pwd2)){
							alert("请输入 以字母开头，长度在6-18之间，只能包含字符、数字和下划线的密码。");
	    				$("#pwd22").focus();
	    				return false;
						}
	    			if(pwd1 != pwd2){
	    				alert("两次输入的密码不一致，请修改");
	    				$("#pwd22").focus();
	    				return false;
	    			}
	    			
	    			$.ajax({
//	    				url:"http://v.wx91go.com/index.php?g=Wap&m=AssetsRegister&a=register&token=dvaglg1469847559&isWeb=1",
						url:"{:U('Index/register',array('token' => 'dvaglg1469847559'))}",
						type:"POST",
	    				dataType:"json",
	    				data:{
	    					type:type,
	    					organization_name:organization_name,
	    					licence_no:licence_no,
	    					legal_person:legal_person,
	    					contacts_person:contacts_person,
	    					register_capital:register_capital,
	    					commpany_nature:commpany_nature,
	    					address:address,
	    					tel:tel,
	    					password:pwd2,
	    					code:code
	    				},
	    				success:function(data){
	    					if(data.status == 1){
	    						window.location.href = "{:U('Assets/investigation_index',array('token' => 'dvaglg1469847559'))}";
	    					}else{
	    						alert(data.msg);
	    					}
	    				}
	    			})
					})
				
				})
		</script>
	</body>
</html>
